package com.sqm.timecard;

import java.text.SimpleDateFormat;
import java.util.Calendar;

/*
 * This object describe one day's check in and check out information
 */
public class DailyRecord
{
    public static final String STATUS_ABNORMAL = "STATUS_ABNORMAL";
    public static final String STATUS_VACATION = "STATUS_VACATION";    
    public static final String STATUS_NROMAL = "NORMAL";
    
    private int dayOfYear;
    private Calendar checkInTime;
    private Calendar takeOffTime;
    private String checkinStatus = STATUS_NROMAL;
    private String takeOffStatus = STATUS_NROMAL;
    private int workDuration; //Minutes
    private boolean workOvertime; //Yes or no
    
	public DailyRecord(int dayOfYear, Calendar checkInTime, Calendar takeOffTime, String checkinStatus, String takeOffStatus)
    {
        super();
        // TODO Auto-generated constructor stub
        this.dayOfYear = dayOfYear;
        this.checkInTime = checkInTime;
        this.takeOffTime = takeOffTime;
        this.checkinStatus = checkinStatus;
        this.takeOffStatus = takeOffStatus;
    }
    public DailyRecord(int dayOfYear)
    {
        super();
        this.dayOfYear = dayOfYear;
    }
    public DailyRecord(Calendar checkInTime, Calendar takeOffTime)
    {
        super();
        this.checkInTime = checkInTime;
        this.takeOffTime = takeOffTime;
    }

    public Calendar getCheckInTime()
    {
        return checkInTime;
    }
    public void setCheckInTime(Calendar checkInTime)
    {
        this.checkInTime = checkInTime;
    }

    public Calendar getTakeOffTime()
    {
        return takeOffTime;
    }
    public void setTakeOffTime(Calendar takeOffTime)
    {
        this.takeOffTime = takeOffTime;
    }
    public int getDayOfYear()
    {
        return dayOfYear;
    }
    public void setDayOfYear(int dayOfYear)
    {
        this.dayOfYear = dayOfYear;
    }
    
    public String toString()
    {
        String line = System.getProperty("line.separator");
        StringBuffer resultString = new StringBuffer();
        resultString.append( line+"   [ DailyRecord: " );
        SimpleDateFormat sdf = new SimpleDateFormat(TimecardProcesser.TIME_FORMAT);
        String checkInTime=this.getCheckInTime()==null?"EMPTY":sdf.format(this.getCheckInTime().getTime());
        String takeOffTime=this.getTakeOffTime()==null?"EMPTY":sdf.format(this.getTakeOffTime().getTime());
        
        try
        {            
            resultString.append("" + " DayOfYear=" + this.getDayOfYear()
                    + " CheckIntime="  
                    + checkInTime
                    +" TakeOffTime="+takeOffTime
                    + " checkInStatus="
                    + this.getCheckinStatus()
                    + " takeOffStatus="
                    + this.getTakeOffStatus()                    
                    );
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return resultString.toString();
    }
    /**
     * @return Returns the checkinStatus.
     */
    public String getCheckinStatus()
    {
        return checkinStatus;
    }
    /**
     * @param checkinStatus The checkinStatus to set.
     */
    public void setCheckinStatus(String checkinStatus)
    {
        this.checkinStatus = checkinStatus;
    }
    /**
     * @return Returns the takeOffStatus.
     */
    public String getTakeOffStatus()
    {
        return takeOffStatus;
    }
    /**
     * @param takeOffStatus The takeOffStatus to set.
     */
    public void setTakeOffStatus(String takeOffStatus)
    {
        this.takeOffStatus = takeOffStatus;
    }

    public int getWorkDuration()
	{
		return workDuration;
	}
	public void setWorkDuration(int workDuration)
	{
		this.workDuration = workDuration;
	}
	/**
	 * @return the workOvertime
	 */
	public boolean isWorkOvertime()
	{
		return workOvertime;
	}
	/**
	 * @param workOvertime the workOvertime to set
	 */
	public void setWorkOvertime(boolean workOvertime)
	{
		this.workOvertime = workOvertime;
	}
}
